package com.haircut.api.project;

import com.haircut.project.service.category.ICategoryService;
import com.haircut.project.service.config.IConfigService;
import com.haircut.project.vo.catetory.CateTreeVo;
import com.haircut.project.vo.config.ConfigVo;
import com.modular.result.RspMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "项目信息")
@RestController
@RequestMapping("/api")
public class ApiProjectController {
    @Autowired
    private ICategoryService categoryService;
    @Autowired
    private IConfigService configService;

    /**
     * 查询分类信息

     * @return
     */
    @ApiOperation(value = "分类信息")
    @GetMapping("/category/tree")
    public RspMessage<List<CateTreeVo>> tree(){
        return RspMessage.success(categoryService.findTree());
    }

    /**
     * 根据分类查询项目信息
     * @param categoryId
     * @return
     */
    @ApiOperation(value = "分类信息")
    @GetMapping("/config/findByCateId")
    public RspMessage<List<ConfigVo>> findByCateId(@ApiParam("分类id") @RequestParam("categoryId") String categoryId){
        return RspMessage.success(configService.findByCateId(categoryId));
    }

}
